package com.hzdy.master.repository.mysql;

import com.hzdy.master.entity.table.FormField;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LALA
 * Date: 2019-03-11
 * Time: 9:58
 */

public interface FormFieldRepository  extends JpaRepository<FormField,Long> {
    @RestResource(path="findBySearch",rel="findBySearch")
    @Query(value = "select * from form_field where 1=1 " +
            "and ( :name is NULL or name like CONCAT('%', :name ,'%'))"+
            "and ( :createTable_id is NULL or createTable_id = :createTable_id )",
            nativeQuery = true)
    Page<FormField> findAllByCreateDateBetweenAndName(
            @Param("name") String name,
            @Param("createTable_id") String createTable_id,
            Pageable pageable);
}
